import moment from "moment";
export function dealTime(
  data: [],
  key: string,
  value1: string,
  value2: string
) {
  let arr = [];
  for (let i = 0; i < data.length; i++) {
    let temp = {
      value: data[i][key],
      label:
        moment(data[i][value1]).format("HH:mm") +
        "-" +
        moment(data[i][value2]).format("HH:mm"),
    };
    arr.push(temp);
  }
  return arr;
}
export function joinTime(data: [], value1: string, value2: string) {
  let arr = [];
  let temp = "";
  for (let i = 0; i < data?.length; i++) {
    temp +=
      moment(data[i][value1]).format("HH:mm") +
      "-" +
      moment(data[i][value2]).format("HH:mm") +
      " ";
  }
  arr.push(temp);
  return arr;
}
export function echoTime(data: [], key: string) {
  let arr = [];
  let flag = 0;
  for (let i = 0; i < data?.length; i++) {
    if (Object.prototype.toString.call(data[i]) === "[object Object]") {
      arr.push(data[i][key]);
    } else {
      flag = 1;
    }
  }
  if (flag) {
    return data;
  } else {
    return arr;
  }
}
